<?php 
	$cateModel = new \Common\Model\Cate;
	$cateData = $cateModel->get();
	// p($cateData);die;
    foreach ($cateData as $key => $value) {
        $cateData[$key]['cname'] = explode('|', $value['cname']);
    }
        // p($cateData);
	$data = getSon($cateData,$name='child',$pid = 0);
	// p($data);die;
	function getSon($cateData,$name='child',$pid=0){
    	// p($cateData);	
        $arr = array();
        foreach ($cateData as $v) {
            if($v['pid'] == $pid){
                $v[$name] = getSon($cateData,$name,$v['cid']);
                $arr[] = $v;
            }
        }
        // p($arr);
        return $arr;
    }

	//**********判断用户名是否存在***********
    if(isset($_SESSION['uinfo']['username'])){//用户名是否存在
    	$username = $_SESSION['uinfo']['username'];
    }
    // p($_SESSION);
    
    // ************购物车中的显示判断*******************
    // 1、*********未登录状态下的显示***************
    $GoodsModel = new \Common\Model\Goods;//商品详情表
    if(isset($_SESSION['cart']['goods'])&!isset($_SESSION['uinfo'])){  //session里面是否存在
    	$GoodsData = isset($_SESSION['cart']['goods']) ? $_SESSION['cart']['goods']:array();
		// p($GoodsData);
    	foreach ($GoodsData as $key => $value) {
    		$GoodsData[$key]['pic'] = $GoodsModel->where(array('gid'=>$value['id']))->pluck('pic');
    		// p($value);
    	}
    	// p($GoodsData);
    }
    // 2、**********登录状态下的显示*****************
    if(isset($_SESSION['uinfo']['uid'])){
    	$uid = $_SESSION['uinfo']['uid'];
    	// p($uid);
    	$CartModel = new \Common\Model\Cart;
    	$GoodsData = $CartModel->where(array('uid'=>$uid))->get();
    	$total = $CartModel->where(array('uid'=>$uid))->count();
    	// p($GoodsData);
    	foreach ($GoodsData as $key => $value) {
    		$GoodsData[$key]['pic'] = $GoodsModel->where(array('gid'=>$value['id']))->pluck('pic');
    		// p($value);
    	}
    	// p($GoodsData);
    }
?>


<header>
	<!-- 最顶部宣传 -->
	<div id="_top">
		<a href=""></a>
	</div>
	<!-- 登录注册版块 -->
	<div id="_login">
		<div class="_login-total">
			<div class="_login-left">
				<span class="_icon"></span>
				<a href="">YOHO!BUY 有货</a>
				<ul class="_left-list">
					<li> 
						<a class="yoho-group" data-cn="集团官网" data-en="YOHO!" href="">YOHO!</a>
					</li>
					<li>
						<a class="yoho-group" data-cn="男生潮流" data-en="YOHO!BOYS" href="">YOHO!BOYS</a>
					</li>
					<li>
						<a class="yoho-group" data-cn="女生潮流" data-en="YOHO!GIRLS" href="">YOHO!GIRLS</a>
					</li>
					<li>
						<a class="yoho-group" data-cn="物趣分享" data-en="YOHO!SHOW" href="">YOHO!SHOW</a>
					</li>
					<li>
						<a class="yoho-group" data-cn="潮流嘉年华" data-en="YO'HOOD" href="">YO'HOOD</a>
					</li>
				</ul>
			</div>
			<div class="_login-right">
				<ul>
				<?php if (isset($username)): ?>
					<li id="login-box">
						<span class="hi">hi~</span>
						[
						<a href="" class="loginbar"><?php echo $username?></a>  <!-- 这里去个人中心 -->
						]
						[
						<a href="<?php echo U('Login/quit')?>" class="registebar">退出</a>
						]
					</li>
				<?php else: ?>
					<li id="login-box">
						<span class="hi">hi~</span>
						[
						<a href="<?php echo U('Login/index')?>" class="loginbar">请登录</a>
						]
						[
						<a href="<?php echo U('Reg/index')?>" class="registebar">免费注册</a>
						]
					</li>
				<?php endif ?>
					
					<li id="myYohoBox" class="myyoho">
						<span class="tag-seprate">|</span>
						<a href="">MY有货</a>
						<span class="icon-bottomarrow"></span>
						<div class="simple-user-center"></div>
					</li>
					<li class="myOrder">
						<span class="tag-seprate">|</span>
						<span class="icon-papers"></span>
						<a href="">我的订单</a>
					</li>
					<li class="mycollect">
						<span class="tag-seprate">|</span>
						<span class="icon-heart"></span>
						<a href="">我的收藏</a>
					</li>
					<li class="message">
						<span class="tag-seprate">|</span>
						<span class="icon-mail"></span>
						<a href="">消息</a>
					</li>
					<li class="phoneapp">
						<span class="tag-seprate">|</span>
						<span class="icon-phone"></span>
						<a href="">手机版</a>
						<div class="download-app-box">
							<div class="qr-img">
								<img src="./Public/Home/Images/qr.png" alt="">
							</div>
							<h3 class="qr-words">扫描二维码</h3>
							<h3 class="qr-words">下载有货手机客户端</h3>
							<h3 class="qr-more"><a href="">更多客户端下载</a></h3>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<!-- 搜索栏(男生) -->
	<div id="head-wrapper">
		<div class="head-wrapper-cate">
			<ul>
				<?php foreach ($data as $v){?>
				<li class="head-list-cur">
					<a href="" class="head-list-cur">
						<span class="name-cn"><?php echo $v['cname']['0']?></span>
						<span class="name-en"><?php echo $v['cname']['1']?></span>
					</a>
				</li>
				<?php }?>
			</ul>
			<div class="head-search">
				<!-- logo显示区中间部分 -->
				<div class="head-logo">
					<img src="./Public/Home/Images/logo/logo_e.png" alt="">
				</div>
				<div class="head-search-right">
					<input type="text" name="" id="search">
					<input type="submit" value="" class="search-submit">
					<div class="head-shop-car">
						<!-- 购物车有商品的时候显示页面 -->
						<?php if (isset($GoodsData)): ?>
							<?php if (isset($_SESSION['cart']['goods'])&!isset($_SESSION['uinfo'])): ?>
								<!-- 未登录状态下session里面的商品总条数 -->
								<span class="head-shop-img"><?php echo $_SESSION['cart']['total_rows']?></span>
							<?php else: ?>
								<!-- 登录状态下显示的购物车总条数 -->
								<span class="head-shop-img"><?php echo $total?></span>
							<?php endif ?>
								<div class="head-car-hide">
									<!-- 这儿开始循环商品列 -->
								<?php foreach ($GoodsData as $v){?>
									<div class="head-goods-list">
										<img src="<?php echo $v['pic']?>" alt="">
										<div class="head-goods-info">
											<p class="goods-info-in"><?php echo $v['name']?></p>
											<p>颜色：灰色 尺码：</p>
										</div>
										<div class="head-goods-price">
											<p>¥<?php echo $v['price']?>×<?php echo $v['num']?></p>
											<a class="goods-del" href="<?php echo U('Cart/del',array('id'=>$v['id']))?>">删除</a>
										</div>
									</div>
								<?php }?>
								<!-- 循环结束 -->
								<div class="head-goods-pay">
									<a href="<?php echo U('Pay/index')?>">去购物车结算</a>
								</div>
							</div>
						<!-- 购物车没有商品的时候的显示页面 -->
						<?php else: ?>

							<span class="head-shop-img">0</span>
							<div class="head-car-hide">
								<img src="./Public/Home/Images/16.png" alt="">
							</div>
						<?php endif ?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="head-list">
		<div class="head-list-name">
			<?php foreach ($data as $v){?>
				<ul class="boys">
					<?php foreach ($v['child'] as $vv){?>
						<li><a href=""><?php echo $vv['cname']['0']?></a></li>
      				<?php }?>
				</ul>
			<?php }?>
		</div>
	</div>
	<div id="third-nav-wrapper">
	<div class="nav-center-content">
		<?php foreach ($data as $v){?>
			<div class="nav-total-left">
				<?php foreach ($v['child'] as $vv){?>
					<?php foreach ($vv['child'] as $vvv){?>
						<p class="nav-tops"><?php echo $vvv['cname']['0']?></p>
						<a href="">333</a>
						<a href="">333</a>
						<a href="">333</a>
						<a href="">333</a>
					<?php }?>
				<?php }?>
			</div>
		<?php }?>
			<div class="nav-total-right-img">
					<img src="./Public/Home/Images/logo/3.jpg" alt="">
					<a href="">IN季新品全面开售</a>
			</div>
	</div>			
	</div>
</header>